// init
import { init } from '../../util/app';
// plugins
import createLoading from 'dva-loading';
import createEffectLock from '../../plugin/effectLock';
import { createLoginSession } from '../../plugin/loginSession';
import { createWebLocalStore, getWebState } from '../../plugin/webLocalStore';
// models
import login from './model/login';
import register from './model/register';
import forgetPassword from './model/forgetPassword';
// router
import router from './router';
// css
import './index.css';

const WEB_STATE_LOGIN = 'WEB_STATE_LOGIN';
let initialState = getWebState(WEB_STATE_LOGIN) || {
    login: {
        channel: 'a3384a9ca39efb36822d0b10b62fbd6c',
		loginRedirect: '/'
    }
}
// 重置插件属性
if(initialState.loading) delete initialState.loading;// 重置loading
if(initialState.effectLock) delete initialState.effectLock;// 重置effectlock

const dvaApp = init({
	initialState,
    plugins: [
        createLoading(),
        createEffectLock(),
        createLoginSession(),
        createWebLocalStore(WEB_STATE_LOGIN)
    ],
    models: [
        login,
        register,
        forgetPassword
    ],
    router,
    start: '#root'
});